package yh.design.factoryactual;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author: zyh
 * @date: 2025/4/15 01:02
 **/
@Component
public class PaymentFactoryRef {

    //支付对象的集合
    public static final Map<Integer,IPaymentService> paymentServiceHashMap = new ConcurrentHashMap<>();

    @Resource(name = "cashPaymentServiceimpl")
    private IPaymentService cashPaymentServiceimpl;


    @Resource(name = "unionPaymentServiceimpl")
    private IPaymentService unionPaymentServiceimpl;

    @Resource(name = "vipCardPaymentServiceimpl")
    private IPaymentService vipCardPaymentServiceimpl;

    @Resource(name = "wechatPaymentServiceimpl")
    private IPaymentService wechatPaymentServiceimpl;

    @PostConstruct
    public void genPaymentFactoryInit(){
        paymentServiceHashMap.put(1,cashPaymentServiceimpl);
        paymentServiceHashMap.put(2,unionPaymentServiceimpl);
        paymentServiceHashMap.put(3,vipCardPaymentServiceimpl);
        paymentServiceHashMap.put(4,wechatPaymentServiceimpl);
    }

}
